﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ListenMusic.AdminSong_ServiceReference;
using System.ServiceModel;
namespace ListenMusic.Models.Reposistory.Admin
{
    public class ManageSongReposistory
    {
        ManageSongServiceClient clientManageSong;
        public List<SongSinger> manageActiveSong(int typeid)
        {
            clientManageSong = new ManageSongServiceClient();
            clientManageSong.ClientCredentials.UserName.UserName = "admin";
            clientManageSong.ClientCredentials.UserName.Password = "123456";
            try {
                SongSinger[] song = clientManageSong.manageActiveSong(typeid);
                return song.ToList();
            }
            catch (FaultException e) { throw e; }
        }        
        public bool activeSong(int songid)
        {
            clientManageSong = new ManageSongServiceClient();
            clientManageSong.ClientCredentials.UserName.UserName = "admin";
            clientManageSong.ClientCredentials.UserName.Password = "123456";
            try
            {
                return clientManageSong.activeSong(songid);                
            }
            catch (FaultException e) { return false; throw e; }
        }
        public List<SongSinger> getAllSongSinger(int typeid)
        {
            clientManageSong = new ManageSongServiceClient();
            clientManageSong.ClientCredentials.UserName.UserName = "admin";
            clientManageSong.ClientCredentials.UserName.Password = "123456";
            try
            {
                SongSinger[] song = clientManageSong.getAllSongSinger(typeid);
                return song.ToList();
            }
            catch (FaultException e) { throw e; }
        }        
        public bool deleteSong_bySongID(int songid)
        {
            clientManageSong = new ManageSongServiceClient();
            clientManageSong.ClientCredentials.UserName.UserName = "admin";
            clientManageSong.ClientCredentials.UserName.Password = "123456";
            try
            {
                return clientManageSong.deleteSong_bySongID(songid);
            }
            catch (FaultException e) { throw e; }
        }
        public bool updateSong(Song s)
        {
            clientManageSong = new ManageSongServiceClient();
            clientManageSong.ClientCredentials.UserName.UserName = "admin";
            clientManageSong.ClientCredentials.UserName.Password = "123456";
            try
            {
                return clientManageSong.updateSong(s);
            }
            catch (FaultException e) { throw e; }
        }
        public SongSinger getSongSinger_bySongID(int songid)
        {
            clientManageSong = new ManageSongServiceClient();
            clientManageSong.ClientCredentials.UserName.UserName = "admin";
            clientManageSong.ClientCredentials.UserName.Password = "123456";
            try
            {
                SongSinger ss = clientManageSong.getSongSinger_bySongID(songid);
                return ss;
            }
            catch (FaultException e) { throw e; }
        }
        public List<SongAlbum> getSongAlbum_byAlbumID(int albumid)
        {
            clientManageSong = new ManageSongServiceClient();
            clientManageSong.ClientCredentials.UserName.UserName = "admin";
            clientManageSong.ClientCredentials.UserName.Password = "123456";
            try
            {
                SongAlbum[] ss = clientManageSong.getSongAlbum_byAlbumID(albumid);
                return ss.ToList();
            }
            catch (FaultException e) { throw e; }
        }
    }
}